#!/bin/sh
#
# This is the script for generating files for a specific Dalton test job.
#
# For the .check file ksh or bash is preferred, otherwise use sh
# (and hope it is not the old Bourne shell, which will not work)
#
if [ -x /bin/ksh ]; then
   CHECK_SHELL='#!/bin/ksh'
elif [ -x /bin/bash ]; then
   CHECK_SHELL='#!/bin/bash'
else
   CHECK_SHELL='#!/bin/sh'
fi


#######################################################################
#  TEST DESCRIPTION
#######################################################################
cat > walk_image.info <<'%EOF%'
   walk_image
   ----------
   Molecule:         NH3
   Wave Function:    SCF / 6-31G** (Atombasis)
   Test Purpose:     Locating a transition state using the IMAGE method
%EOF%

#######################################################################
#  MOLECULE INPUT
#######################################################################
cat > walk_image.mol <<'%EOF%'
ATOMBASIS
Location of saddle point (transition state) using IMAGE method

Atomtypes=2 Nosymmetry Cartesian
Charge=7.0 Atoms=1      Basis=6-31G**
N     0.0  0.0  0.0
Charge=1.0 Atoms=3      Basis=6-31G**
H     1.7      0.0     0.0
H    -1.3841   0.9919  0.0
H    -1.3841  -0.9919  0.0
%EOF%

#######################################################################
#  DALTON INPUT
#######################################################################
cat > walk_image.dal <<'%EOF%'
**DALTON INPUT
.WALK
*WALK
.IMAGE
**WAVE FUNCTION
.HF
*SCF INPUT
.THRESH
1.0d-6
**PROPERTIES
.VIBANA
.POPANA
**END OF DALTON INPUT
%EOF%
#######################################################################



#######################################################################

#######################################################################
#  CHECK SCRIPT
#######################################################################
echo $CHECK_SHELL >walk_image.check
cat >>walk_image.check <<'%EOF%'
log=$1

if [ `uname` = Linux ]; then
   GREP="egrep -a"
else
   GREP="egrep"
fi

# Using WALK module
CRIT1=`$GREP "Commencing geometry optimization based on \.WALK" $log | wc -l`
TEST[1]=`expr	$CRIT1`
CTRL[1]=1
ERROR[1]="WALK MODULE NOT USED"

# Basis set
CRIT1=`$GREP "N * 1 * 7\.0000 * 28 * 15 * \[10s4p1d\|3s2p1d\]" $log | wc -l`
CRIT2=`$GREP "H * 3 * 1\.0000 * 7 * 5 * \[4s1p\|2s1p\]" $log | wc -l`
CRIT3=`$GREP "total\: * 4 * 10\.0000 * 49 * 30" $log | wc -l`
TEST[2]=`expr	$CRIT1 \+ $CRIT2 \+ $CRIT3`
CTRL[2]=3
ERROR[2]="ATOMBASIS NOT READ CORRECTLY"

# Cartesian function
CRIT1=`$GREP "Cartesian basis used" $log | wc -l`
TEST[3]=`expr	$CRIT1`
CTRL[3]=1
ERROR[3]="CARTESIAN BASIS FUNCTIONS NOT USED"

# Geometry
CRIT1=`$GREP "Total number of coordinates\: * 12" $log | wc -l`
CRIT2=`$GREP "1 * x * (0| )\.0000000000" $log | wc -l`
CRIT3=`$GREP "2 * y * (0| )\.0000000000" $log | wc -l`
CRIT4=`$GREP "3 * z * (0| )\.0000000000" $log | wc -l`
CRIT5=`$GREP "4 * x * 1\.7000000000" $log | wc -l`
CRIT6=`$GREP "5 * y * (0| )\.0000000000" $log | wc -l`
CRIT7=`$GREP "6 * z * (0| )\.0000000000" $log | wc -l`
CRIT8=`$GREP "7 * x * \-1\.3841000000" $log | wc -l`
CRIT9=`$GREP "8 * y * (0| )\.9919000000" $log | wc -l`
CRIT10=`$GREP "9 * z * (0| )\.0000000000" $log | wc -l`
CRIT11=`$GREP "10 * x * \-1\.3841000000" $log | wc -l`
CRIT12=`$GREP "11 * y * (\-0|\-)\.9919000000" $log | wc -l`
CRIT13=`$GREP "12 * z * (0| )\.0000000000" $log | wc -l`
TEST[4]=`expr	$CRIT1 \+ $CRIT2 \+ $CRIT3 \+ $CRIT4 \+ $CRIT5 \+ $CRIT6 \+ \
		$CRIT7 \+ $CRIT8 \+ $CRIT9 \+ $CRIT10 \+ $CRIT11 \+ $CRIT12 \+ \
		$CRIT13`
CTRL[4]=13
ERROR[4]="MOLECULAR GEOMETRY NOT READ CORRECTLY"

# Initial energy
CRIT1=`$GREP "Final * HF energy\: * \-56\.0799902961[67][0-9]" $log | wc -l`
TEST[5]=`expr	$CRIT1`
CTRL[5]=1
ERROR[5]="INITIAL ENERGY NOT CORRECT"

# Optimization setup
CRIT1=`$GREP "Walk type\: Level\-shifted Newton walk \(mode following\)" $log | wc -l`
CRIT2=`$GREP "Minimization of image surface " $log | wc -l`
CRIT3=`$GREP "Initial image mode\: 1" $log | wc -l`
TEST[6]=`expr	$CRIT1 \+ $CRIT2 \+ $CRIT3`
CTRL[6]=3
ERROR[6]="WALK NOT SET UP CORRECTLY"

# Initial gradient
CRIT1=`$GREP "N * (0| )\.01795(5|6)...[0-9] * (\-0|\-|0| )\.0000000000 * (\-0|\-|0| )\.0000000000" $log | wc -l`
CRIT2=`$GREP "H * (\-0|\-)\.10969[12]...[0-9] * (\-0|\-|0| )\.0000000000 * (\-0|\-|0| )\.0000000000" $log | wc -l`
CRIT3=`$GREP "H * (0| )\.04586(7|8)...[0-9] * (\-0|\-)\.179532...[0-9] * (\-0|\-|0| )\.0000000000" $log | wc -l`
CRIT4=`$GREP "H * (0| )\.04586(7|8)...[0-9] * (0| )\.179532...[0-9] * (\-0|\-|0| )\.0000000000" $log | wc -l`
TEST[7]=`expr	$CRIT1 \+ $CRIT2 \+ $CRIT3 \+ $CRIT4`
CTRL[7]=4
ERROR[7]="INITIAL GRADIENT NOT CORRECT"

# Initial Hessian
CRIT1=`$GREP "N * x * 2\.14484[0-9]" $log | wc -l`
CRIT2=`$GREP "N * y * (\-0|\-|0| )\.000000 * (0| )\.62743[0-9]" $log | wc -l`
CRIT3=`$GREP "N * z * (\-0|\-|0| )\.000000 * (\-0|\-|0| )\.000000 * (\-0|\-)\.32113[0-9]" $log | wc -l`
CRIT4=`$GREP "H * x * (\-0|\-)\.98914[0-9] * (\-0|\-|0| )\.000000 * (\-0|\-|0| )\.000000 * (0| )\.97710[0-9]" $log | wc -l`
CRIT5=`$GREP "H * y * (\-0|\-|0| )\.000000 * (0| )\.01719[0-9] * (\-0|\-|0| )\.000000 * (\-0|\-|0| )\.000000 * (\-0|\-)\.02953[0-9]" $log | wc -l`
CRIT6=`$GREP "H * z * (\-0|\-|0| )\.000000 * (\-0|\-|0| )\.000000 * (0| )\.14994[0-9] * (\-0|\-|0| )\.000000 * (\-0|\-|0| )\.000000 * (\-0|\-)\.10286[0-9]" $log | wc -l`
CRIT7=`$GREP "H * x * (\-0|\-)\.57785[0-9] * (0| )\.45544[0-9] * (\-0|\-|0| )\.000000 * (0| )\.00601[0-9] * (0| )\.02137[0-9] * (\-0|\-|0| )\.000000" $log | wc -l`
CRIT8=`$GREP "H * y * (0| )\.45304[0-9] * (\-0|\-)\.32231[0-9] * (\-0|\-|0| )\.000000 * (\-0|\-)\.01206[0-9] * (0| )\.006170 * (\-0|\-|0| )\.000000" $log | wc -l`
CRIT9=`$GREP "H * z * (\-0|\-|0| )\.000000 * (\-0|\-|0| )\.000000 * (0| )\.08559[0-9] * (\-0|\-|0| )\.000000 * (\-0|\-|0| )\.000000 * (\-0|\-)\.02354[0-9]" $log | wc -l`
CRIT10=`$GREP "H * x * (\-0|\-)\.57785[0-9] * (\-0|\-)\.45544[0-9] * (\-0|\-|0| )\.000000 * (0| )\.00601[0-9] * (\-0|\-)\.02137[0-9] * (\-0|\-|0| )\.000000" $log | wc -l`
CRIT11=`$GREP "H * y * (\-0|\-)\.45304[0-9] * (\-0|\-)\.32231[0-9] * (\-0|\-|0| )\.000000 * (0| )\.01206[0-9] * (0| )\.00617[0-9] * (\-0|\-|0| )\.000000" $log | wc -l`
CRIT12=`$GREP "H * x * (0| )\.54640[0-9]" $log | wc -l`
CRIT13=`$GREP "H * y * (\-0|\-)\.45889[0-9] * (0| )\.42590[0-9]" $log | wc -l`
CRIT14=`$GREP "H * z * (\-0|\-|0| )\.000000 * (\-0|\-|0| )\.000000 * (\-0|\-)\.12152[0-9]" $log | wc -l`
CRIT15=`$GREP "H * x * (0| )\.02542[0-9] * (0| )\.01791[0-9] * (\-0|\-|0| )\.000000 * (0| )\.54640[0-9]" $log | wc -l`
CRIT16=`$GREP "H * y * (\-0|\-)\.01791[0-9] * (\-0|\-)\.10976[0-9] * (\-0|\-|0| )\.000000 * (0| )\.45889[0-9] * (0| )\.42590[0-9]" $log | wc -l`
CRIT17=`$GREP "H * z * (\-0|\-|0| )\.000000 * (\-0|\-|0| )\.000000 * (0| )\.05947[0-9] * (\-0|\-|0| )\.000000 * (\-0|\-|0| )\.000000 * (\-0|\-)\.12152[0-9]" $log | wc -l`
TEST[8]=`expr	$CRIT1 \+ $CRIT2 \+ $CRIT3 \+ $CRIT4 \+ $CRIT5 \+ $CRIT6 \+ \
		$CRIT7 \+ $CRIT8 \+ $CRIT9 \+ $CRIT10 \+ $CRIT11 \+ $CRIT12 \+ \
		$CRIT13 \+ $CRIT14 \+ $CRIT15 \+ $CRIT16 \+ $CRIT17`
CTRL[8]=18
ERROR[8]="INITIAL HESSIAN NOT CORRECT"

# Initial step
CRIT1=`$GREP "H * (0| )\.0066288..[0-9] * (\-0|\-|0| )\.0000000000 * (\-0|\-|0| )\.0000000000" $log | wc -l`
CRIT2=`$GREP "H * (0| )\.0520110..[0-9] * (0| )\.3408094..[0-9] * (\-0|\-|0| )\.0000000000" $log | wc -l`
CRIT3=`$GREP "H * (0| )\.0520110..[0-9] * (\-0|\-)\.3408094..[0-9] * (\-0|\-|0| )\.0000000000" $log | wc -l`
TEST[9]=`expr	$CRIT1 \+ $CRIT2 \+ $CRIT3`
CTRL[9]=3
ERROR[9]="INITIAL STEP NOT CORRECT"

# Second energy
CRIT1=`$GREP "Final * HF energy\: * \-56\.1653288(7|8)...[0-9]" $log | wc -l`
TEST[10]=`expr	$CRIT1`
CTRL[10]=1
ERROR[10]="SECOND ENERGY NOT CORRECT"

# Second gradient
CRIT1=`$GREP "N * (0| )\.03707(1|2)...[0-9] * (\-0|\-|0| )\.0000000000 * (\-0|\-|0| )\.0000000000" $log | wc -l`
CRIT2=`$GREP "H * (\-0|\-)\.021343...[0-9] * (\-0|\-|0| )\.0000000000 * (\-0|\-|0| )\.0000000000" $log | wc -l`
CRIT3=`$GREP "H * (\-0|\-)\.007864...[0-9] * (\-0|\-)\.06472(8|9)...[0-9] * (\-0|\-|0| )\.0000000000" $log | wc -l`
CRIT4=`$GREP "H * (\-0|\-)\.007864...[0-9] * (0| )\.06472(8|9)...[0-9] * (\-0|\-|0| )\.0000000000" $log | wc -l`
TEST[11]=`expr	$CRIT1 \+ $CRIT2 \+ $CRIT3 \+ $CRIT4`
CTRL[11]=4
ERROR[11]="SECOND GRADIENT NOT CORRECT"

# Second Hessian
CRIT1=`$GREP "N * x * 1\.31366" $log | wc -l`
CRIT2=`$GREP "N * y * (\-0|\-|0| )\.000000 * (0| )\.84725" $log | wc -l`
CRIT3=`$GREP "N * z * (\-0|\-|0| )\.000000 * (\-0|\-|0| )\.000000 * (\-0|\-)\.13670" $log | wc -l`
CRIT4=`$GREP "H * x * (\-0|\-)\.66731[0-9] * (\-0|\-|0| )\.000000 * (\-0|\-|0| )\.000000 * (0| )\.6683[67]" $log | wc -l`
CRIT5=`$GREP "H * y * (\-0|\-|0| )\.000000 * (\-0|\-)\.06274[0-9] * (\-0|\-|0| )\.000000 * (\-0|\-|0| )\.000000 * (0| )\.04136[0-9]" $log | wc -l`
CRIT6=`$GREP "H * z * (\-0|\-|0| )\.000000 * (\-0|\-|0| )\.000000 * (0| )\.06715[0-9] * (\-0|\-|0| )\.000000 * (\-0|\-|0| )\.000000 * (\-0|\-)\.03401[0-9]" $log | wc -l`
CRIT7=`$GREP "H * x * (\-0|\-)\.32317[0-9] * (0| )\.30282[0-9] * (\-0|\-|0| )\.000000 * (\-0|\-)\.00052[0-9] * (0| )\.02641[0-9] * (\-0|\-|0| )\.000000" $log | wc -l`
CRIT8=`$GREP "H * y * (0| )\.29203[0-9] * (\-0|\-)\.39225[0-9] * (\-0|\-|0| )\.000000 * (\-0|\-)\.01070[0-9] * (0| )\.01069[0-9] * (\-0|\-|0| )\.000000" $log | wc -l`
CRIT9=`$GREP "H * z * (\-0|\-|0| )\.000000 * (\-0|\-|0| )\.000000 * (0| )\.03477[0-9] * (\-0|\-|0| )\.000000 * (\-0|\-|0| )\.000000 * (\-0|\-)\.01656[0-9]" $log | wc -l`
CRIT10=`$GREP "H * x * (\-0|\-)\.32317[0-9] * (\-0|\-)\.30282[0-9] * (\-0|\-|0| )\.000000 * (\-0|\-)\.00052[0-9] * (\-0|\-)\.02641[0-9] * (\-0|\-|0| )\.000000" $log | wc -l`
CRIT11=`$GREP "H * y * (\-0|\-)\.29203[0-9] * (\-0|\-)\.39225[0-9] * (\-0|\-|0| )\.000000 * (0| )\.01070[0-9] * (0| )\.01069[0-9] * (\-0|\-|0| )\.000000" $log | wc -l`
CRIT12=`$GREP "H * x * (0| )\.30644[0-9]" $log | wc -l`
CRIT13=`$GREP "H * y * (\-0|\-)\.30528[0-9] * (0| )\.43186[0-9]" $log | wc -l`
CRIT14=`$GREP "H * z * (\-0|\-|0| )\.000000 * (\-0|\-|0| )\.000000 * (\-0|\-)\.03339[0-9]" $log | wc -l`
CRIT15=`$GREP "H * x * (0| )\.01725[0-9] * (0| )\.02394[0-9] * (\-0|\-|0| )\.000000 * (0| )\.30644[0-9]" $log | wc -l`
CRIT16=`$GREP "H * y * (\-0|\-)\.02394[0-9] * (\-0|\-)\.05029[0-9] * (\-0|\-|0| )\.000000 * (0| )\.30528[0-9] * (0| )\.43186[0-9]" $log | wc -l`
CRIT17=`$GREP "H * z * (\-0|\-|0| )\.000000 * (\-0|\-|0| )\.000000 * (0| )\.0151(7|8)[0-9] * (\-0|\-|0| )\.000000 * (\-0|\-|0| )\.000000 * (\-0|\-)\.03339[0-9]" $log | wc -l`
TEST[12]=`expr	$CRIT1 \+ $CRIT2 \+ $CRIT3 \+ $CRIT4 \+ $CRIT5 \+ $CRIT6 \+ \
		$CRIT7 \+ $CRIT8 \+ $CRIT9 \+ $CRIT10 \+ $CRIT11 \+ $CRIT12 \+ \
		$CRIT13 \+ $CRIT14 \+ $CRIT15 \+ $CRIT16 \+ $CRIT17`
CTRL[12]=18
ERROR[12]="SECOND HESSIAN NOT CORRECT"

# Final energy
CRIT1=`$GREP "Final * HF energy\: * \-56\.1865373(5|6)...[0-9]" $log | wc -l`
TEST[13]=`expr	$CRIT1`
CTRL[13]=1
ERROR[13]="THIRD ENERGY NOT CORRECT"

# Convergence
CRIT1=`$GREP "\@ * Geometry optimization has converged\." $log | wc -l`
TEST[14]=`expr	$CRIT1`
CTRL[14]=1
ERROR[14]="GEOMETRY OPTIMIZATION NOT CONVERGED"

# Hessian eigenvalues
CRIT1=`$GREP "\@ * 1 * 1 * \-*0*\.000000.... * \-0*\.10374" $log | wc -l`
CRIT2=`$GREP "\@ * 1 * 2 * \-*0*\.000000.... * 0*\.15784" $log | wc -l`
CRIT3=`$GREP "\@ * 1 * 3 * \-*0*\.000000.... * 0*\.15784" $log | wc -l`
CRIT4=`$GREP "\@ * 1 * 4 * \-*0*\.000000.... * 0*\.56253" $log | wc -l`
CRIT5=`$GREP "\@ * 1 * 5 * \-*0*\.000000.... * 1\.47291" $log | wc -l`
CRIT6=`$GREP "\@ * 1 * 6 * \-*0*\.000000.... * 1\.47291" $log | wc -l`
TEST[15]=`expr	$CRIT1 \+ $CRIT2 \+ $CRIT3 \+ $CRIT4 \+ $CRIT5 \+ $CRIT6`
CTRL[15]=6
ERROR[15]="FINAL GRADIENT AND HESSIAN EIGENVALUES NOT CORRECT"

# Final geometry
CRIT1=`$GREP "N * \-0*\.267050.... * \-*0*\.000000.... * \-*0*\.00000....." $log | wc -l`
CRIT2=`$GREP "H *    1\.597245.... * \-*0*\.000000.... * \-*0*\.000000...." $log | wc -l`
CRIT3=`$GREP "H *  \-1\.199197.... *     1\.614526.... * \-*0*\.000000...." $log | wc -l`
CRIT4=`$GREP "H *  \-1\.199197.... *   \-1\.614526.... * \-*0*\.000000...." $log | wc -l`
TEST[16]=`expr	$CRIT1 \+ $CRIT2 \+ $CRIT3 \+ $CRIT4`
CTRL[16]=16
ERROR[16]="FINAL GEOMETRY NOT CORRECT"

# Final analysis
CRIT1=`$GREP "Vibrational analysis" $log | wc -l`
CRIT2=`$GREP "Cioslowski population analysis and static polarizabilities only\." $log | wc -l`
TEST[17]=`expr	$CRIT1 \+ $CRIT2`
CTRL[17]=3
ERROR[17]="FINAL ANALYSIS NOT SET UP CORRECTLY"

# Dipole moment gradient
 CRIT1=`$GREP "N * x * \-0*\.465254.. * \-*0*\.000000.. * \-*0*\.000000.." $log | wc -l`
 CRIT2=`$GREP "N * y * \-*0*\.000000.. * \-0*\.46525(4|5).. * \-*0*\.000000.." $log | wc -l`
 CRIT3=`$GREP "N * z * \-*0*\.000000.. * \-*0*\.000000.. * \-1\.218508.." $log | wc -l`
 CRIT4=`$GREP "H * x * 0*\.151407.. * \-*0*\.000000.. * \-*0*\.000000.." $log | wc -l`
 CRIT5=`$GREP "H * y * \-*0*\.000000.. * 0*\.158762.. * \-*0*\.000000.." $log | wc -l`
 CRIT6=`$GREP "H * z * \-*0*\.000000.. * \-*0*\.000000.. * 0*\.406169.." $log | wc -l`
 CRIT7=`$GREP "H * x * 0*\.156923.. * 0*\.003184.. * \-*0*\.000000.." $log | wc -l`
 CRIT8=`$GREP "H * y * 0*\.003184.. * 0*\.153246.. * \-*0*\.000000.." $log | wc -l`
 CRIT9=`$GREP "H * x * 0*\.156923.. * \-0*\.003184.. * \-*0*\.000000.." $log | wc -l`
CRIT10=`$GREP "H * y * \-0*\.003184.. * 0*\.153246.. * \-*0*\.000000.." $log | wc -l`
TEST[18]=`expr	$CRIT1 \+ $CRIT2 \+ $CRIT3 \+ $CRIT4 \+ $CRIT5 \+ $CRIT6 \+ \
		$CRIT7 \+ $CRIT8 \+ $CRIT9 \+ $CRIT10`
CTRL[18]=12
ERROR[18]="DIPOLE MOMENT GRADIENT NOT CORRECT"

# Cioslowski charges
CRIT1=`$GREP "N * (\-0|\-)\.7163(3|4)[0-9]" $log | wc -l`
CRIT2=`$GREP "H * (0| )\.23878[0-9]" $log | wc -l`
TEST[19]=`expr	$CRIT1 \+ $CRIT2`
CTRL[19]=4
ERROR[19]="CIOSLOWSKI CHARGES NOT CORRECT"

# Static polarizabilities
CRIT1=`$GREP "Ex * 8\.4795[34]. * (0| |\-0|\-)\.000000 * (0| |\-0|\-)\.000000" $log | wc -l`
CRIT2=`$GREP "Ey * (0| |\-0|\-)\.000000 * 8\.47953. * (0| |\-0|\-)\.000000" $log | wc -l`
CRIT3=`$GREP "Ez * (0| |\-0|\-)\.000000 * (0| |\-0|\-)\.000000 * 4\.13429" $log | wc -l`
TEST[20]=`expr	$CRIT1 \+ $CRIT2 \+ $CRIT3`
CTRL[20]=3
ERROR[20]="STATIC POLARIZABILITIES NOT CORRECT"

# Rotational constants
CRIT1=`$GREP "343486\..... * 343486\..... * 171743\.1... MHz" $log | wc -l`
CRIT2=`$GREP "11\.4574.. * 11\.4574.. * 5\.72873. cm\-1" $log | wc -l`
TEST[21]=`expr	$CRIT1 \+ $CRIT2`
CTRL[21]=2
ERROR[21]="ROTATIONAL CONSTANTS NOT CORRECT"

# Frequencies
CRIT1=`$GREP "1 * A * 4065\.9[0-9] * (0| )\.01852[0-9] * 43\.34[0-9] * 1\.025[0-9]" $log | wc -l`
CRIT2=`$GREP "2 * A * 4065\.8[0-9] * (0| )\.01852[0-9] * 43\.34[0-9] * 1\.025[0-9]" $log | wc -l`
CRIT3=`$GREP "3 * A * 3840\.5[0-9] * (0| )\.01749[0-9] * (0| )\.000 * (0| )\.0000" $log | wc -l`
CRIT4=`$GREP "4 * A * 1714\.3[0-9] * (0| )\.00781[0-9] * 41\.55[0-9] * (0| )\.983[0-9]" $log | wc -l`
CRIT5=`$GREP "5 * A * 1714\.3[0-9] * (0| )\.00781[0-9] * 41\.55[0-9] * (0| )\.983[0-9]" $log | wc -l`
CRIT6=`$GREP "6 * A * 909\.3[0-9]i * (0| )\.00414[0-9]i" $log | wc -l`
TEST[22]=`expr	$CRIT1 \+ $CRIT2 \+ $CRIT3 \+ $CRIT4 \+ $CRIT5 \+ $CRIT6`
CTRL[22]=6
ERROR[22]="FREQUENCIES NOT CORRECT"

# Partition function
CRIT1=`$GREP "50\.00 * 3\.180[0-9](D|E)\+04 * 13\.9[0-9] * 1\.0000 * 4\.44249[0-9](D|E)\+05" $log | wc -l`
CRIT2=`$GREP "200\.00 * 1\.017[0-9](D|E)\+06 * 107\.3[0-9] * 1\.0000 * 1\.09285[0-9](D|E)\+08" $log | wc -l`
CRIT3=`$GREP "273\.15 * 2\.218[0-9](D|E)\+06 * 170\.7[0-9] * 1\.000[0-9] * 3\.78940[0-9](D|E)\+08" $log | wc -l`
CRIT4=`$GREP "298\.15 * 2\.761[0-9](D|E)\+06 * 194\.5[0-9] * 1\.000[0-9] * 5\.37600[0-9](D|E)\+08" $log | wc -l`
CRIT5=`$GREP "500\.00 * 1\.005[0-9](D|E)\+07 * 421\.0[0-9] * 1\.014[0-9] * 4\.29605[0-9](D|E)\+09" $log | wc -l`
CRIT6=`$GREP "800\.00 * 3\.256[0-9](D|E)\+07 * 850\.3[0-9] * 1\.100[0-9] * 3\.04869[0-9](D|E)\+10" $log | wc -l`
CRIT7=`$GREP "2000\.00 * 3\.218[0-9](D|E)\+08 * 3354\.3[0-9] * 2\.373[0-9] * 2\.5620(3|4)[0-9](D|E)\+12" $log | wc -l`
TEST[23]=`expr	$CRIT1 \+ $CRIT2 \+ $CRIT3 \+ $CRIT4 \+ $CRIT5 \+ $CRIT6 \+ \
		$CRIT7`
CTRL[23]=7
ERROR[23]="PARTITION FUNCTION NOT CORRECT"

PASSED=1
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
do
   if [ ${TEST[i]} -ne ${CTRL[i]} ]; then
     echo "${ERROR[i]} ( test = ${TEST[i]}; control = ${CTRL[i]} ); "
     PASSED=0
   fi
done

if [ $PASSED -eq 1 ]
then
  echo TEST ENDED PROPERLY
  exit 0
else
  echo THERE IS A PROBLEM
  exit 1
fi

%EOF%
#######################################################################
